<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.7"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>qLibc: extensions/qconfig.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">qLibc
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.7 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('qconfig_8c.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">qconfig.c File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>INI-style configuration file parser.  
<a href="#details">More...</a></p>

<p><a href="qconfig_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ab62078f483e0002c4cd7d8f993a674a1"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qconfig_8c.html#ab62078f483e0002c4cd7d8f993a674a1">_INCLUDE_DIRECTIVE</a>&#160;&#160;&#160;&quot;@INCLUDE &quot;</td></tr>
<tr class="separator:ab62078f483e0002c4cd7d8f993a674a1"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:afcd4cc94bda4c854e3d26e5e358d5507"><td class="memItemLeft" align="right" valign="top">qlisttbl_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qconfig_8c.html#afcd4cc94bda4c854e3d26e5e358d5507">qconfig_parse_file</a> (qlisttbl_t *tbl, const char *filepath, char sepchar)</td></tr>
<tr class="memdesc:afcd4cc94bda4c854e3d26e5e358d5507"><td class="mdescLeft">&#160;</td><td class="mdescRight">Load &amp; parse configuration file.  <br /></td></tr>
<tr class="separator:afcd4cc94bda4c854e3d26e5e358d5507"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afe9f5bb5dd171682d5d27e51151eac93"><td class="memItemLeft" align="right" valign="top">qlisttbl_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qconfig_8c.html#afe9f5bb5dd171682d5d27e51151eac93">qconfig_parse_str</a> (qlisttbl_t *tbl, const char *str, char sepchar)</td></tr>
<tr class="memdesc:afe9f5bb5dd171682d5d27e51151eac93"><td class="mdescLeft">&#160;</td><td class="mdescRight">Parse string.  <br /></td></tr>
<tr class="separator:afe9f5bb5dd171682d5d27e51151eac93"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>INI-style configuration file parser. </p>

<p class="definition">Definition in file <a class="el" href="qconfig_8c_source.html">qconfig.c</a>.</p>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ab62078f483e0002c4cd7d8f993a674a1" name="ab62078f483e0002c4cd7d8f993a674a1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab62078f483e0002c4cd7d8f993a674a1">&#9670;&#160;</a></span>_INCLUDE_DIRECTIVE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define _INCLUDE_DIRECTIVE&#160;&#160;&#160;&quot;@INCLUDE &quot;</td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="qconfig_8c_source.html#l00047">47</a> of file <a class="el" href="qconfig_8c_source.html">qconfig.c</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="afcd4cc94bda4c854e3d26e5e358d5507" name="afcd4cc94bda4c854e3d26e5e358d5507"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afcd4cc94bda4c854e3d26e5e358d5507">&#9670;&#160;</a></span>qconfig_parse_file()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">qlisttbl_t * qconfig_parse_file </td>
          <td>(</td>
          <td class="paramtype">qlisttbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>filepath</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char&#160;</td>
          <td class="paramname"><em>sepchar</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Load &amp; parse configuration file. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>a pointer of qlisttbl_t. NULL will generate a new table. </td></tr>
    <tr><td class="paramname">filepath</td><td>configuration file path </td></tr>
    <tr><td class="paramname">sepchar</td><td>separater used in configuration file to divice key and value</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of qlisttbl_t in case of successful, otherwise(file not found) returns NULL</dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor"># This is &quot;config.conf&quot;</span> file.</div>
<div class="line"><span class="preprocessor"># A line which starts with # character is comment</span></div>
<div class="line"> </div>
<div class="line">@INCLUDE config.def  =&gt; include <span class="stringliteral">&#39;config.def&#39;</span> file.</div>
<div class="line"> </div>
<div class="line">prefix=/tmp        =&gt; set <span class="keyword">static</span> value. <span class="stringliteral">&#39;prefix&#39;</span> is the key <span class="keywordflow">for</span> <span class="keyword">this</span> entry.</div>
<div class="line">log=${prefix}/log  =&gt; <a class="code hl_function" href="qhttpclient_8c.html#af16a3eb0912e8b5d4896466632d9c843">get</a> the value from previously defined key <span class="stringliteral">&#39;prefix&#39;</span>.</div>
<div class="line">user=${%USER}      =&gt; <a class="code hl_function" href="qhttpclient_8c.html#af16a3eb0912e8b5d4896466632d9c843">get</a> environment variable.</div>
<div class="line">host=${!/bin/hostname -s}  =&gt; run external command and <a class="code hl_function" href="qhttpclient_8c.html#ae9ac3bd43c11509c0cbd8fb284bf13eb">put</a> it<span class="stringliteral">&#39;s output.</span></div>
<div class="line"><span class="stringliteral">id=${user}@${host}</span></div>
<div class="line"><span class="stringliteral"></span> </div>
<div class="line"><span class="stringliteral"># now entering into &#39;</span>system<span class="stringliteral">&#39; section.</span></div>
<div class="line"><span class="stringliteral">[system]           =&gt; a key &#39;</span>system.<span class="stringliteral">&#39; with value &#39;</span>system<span class="stringliteral">&#39; will be inserted.</span></div>
<div class="line"><span class="stringliteral">ostype=${%OSTYPE}  =&gt; &#39;</span>system.ostype<span class="stringliteral">&#39; is the key for this entry.</span></div>
<div class="line"><span class="stringliteral">machtype=${%MACHTYPE}  =&gt; &#39;</span>system.machtype<span class="stringliteral">&#39; is the key for this entry.</span></div>
<div class="line"><span class="stringliteral"></span> </div>
<div class="line"><span class="stringliteral"># entering into &#39;</span>daemon<span class="stringliteral">&#39; section.</span></div>
<div class="line"><span class="stringliteral">[daemon]</span></div>
<div class="line"><span class="stringliteral">port=1234</span></div>
<div class="line"><span class="stringliteral">name=${user}_${host}_${system.ostype}_${system.machtype}</span></div>
<div class="line"><span class="stringliteral"></span> </div>
<div class="line"><span class="stringliteral"># escape section. (go back to root)</span></div>
<div class="line"><span class="stringliteral">[]</span></div>
<div class="line"><span class="stringliteral">rev=822</span></div>
<div class="ttc" id="aqhttpclient_8c_html_ae9ac3bd43c11509c0cbd8fb284bf13eb"><div class="ttname"><a href="qhttpclient_8c.html#ae9ac3bd43c11509c0cbd8fb284bf13eb">put</a></div><div class="ttdeci">static bool put(qhttpclient_t *client, const char *uri, int fd, off_t length, int *rescode, qlisttbl_t *reqheaders, qlisttbl_t *resheaders, bool(*callback)(void *userdata, off_t sentbytes), void *userdata)</div><div class="ttdoc">qhttpclient-&gt;put(): Uploads a file to the remote host using PUT method.</div><div class="ttdef"><b>Definition</b> <a href="qhttpclient_8c_source.html#l00926">qhttpclient.c:926</a></div></div>
<div class="ttc" id="aqhttpclient_8c_html_af16a3eb0912e8b5d4896466632d9c843"><div class="ttname"><a href="qhttpclient_8c.html#af16a3eb0912e8b5d4896466632d9c843">get</a></div><div class="ttdeci">static bool get(qhttpclient_t *client, const char *uri, int fd, off_t *savesize, int *rescode, qlisttbl_t *reqheaders, qlisttbl_t *resheaders, bool(*callback)(void *userdata, off_t recvbytes), void *userdata)</div><div class="ttdoc">qhttpclient-&gt;get(): Downloads a file from the remote host using GET method.</div><div class="ttdef"><b>Definition</b> <a href="qhttpclient_8c_source.html#l00694">qhttpclient.c:694</a></div></div>
</div><!-- fragment --><div class="fragment"><div class="line"><span class="preprocessor"># This is &quot;config.def&quot;</span> file.</div>
<div class="line">prefix = /usr/local</div>
<div class="line">bin = ${prefix}/bin</div>
<div class="line">log = ${prefix}/log</div>
<div class="line">user = unknown</div>
<div class="line">host = unknown</div>
</div><!-- fragment --><div class="fragment"><div class="line">qlisttbl_t *tbl = <a class="code hl_function" href="qconfig_8c.html#afcd4cc94bda4c854e3d26e5e358d5507">qconfig_parse_file</a>(NULL, <span class="stringliteral">&quot;config.conf&quot;</span>, <span class="charliteral">&#39;=&#39;</span>, <span class="keyword">true</span>);</div>
<div class="line">tbl-&gt;debug(tbl, stdout);</div>
<div class="line"> </div>
<div class="line">[Output]</div>
<div class="line">bin=/usr/local/bin? (15)</div>
<div class="line">prefix=/tmp? (5)</div>
<div class="line">log=/tmp/log? (9)</div>
<div class="line">user=seungyoung.kim? (9)</div>
<div class="line">host=eng22? (6)</div>
<div class="line"><span class="keywordtype">id</span>=seungyoung.kim@eng22? (15)</div>
<div class="line">system.=system? (7)</div>
<div class="line">system.ostype=linux? (6)</div>
<div class="line">system.machtype=x86_64? (7)</div>
<div class="line">daemon.=daemon? (7)</div>
<div class="line">daemon.port=1234? (5)</div>
<div class="line">daemon.name=seungyoung.kim_eng22_linux_x86_64? (28)</div>
<div class="line">rev=822? (4)</div>
<div class="ttc" id="aqconfig_8c_html_afcd4cc94bda4c854e3d26e5e358d5507"><div class="ttname"><a href="qconfig_8c.html#afcd4cc94bda4c854e3d26e5e358d5507">qconfig_parse_file</a></div><div class="ttdeci">qlisttbl_t * qconfig_parse_file(qlisttbl_t *tbl, const char *filepath, char sepchar)</div><div class="ttdoc">Load &amp; parse configuration file.</div><div class="ttdef"><b>Definition</b> <a href="qconfig_8c_source.html#l00126">qconfig.c:126</a></div></div>
</div><!-- fragment --> 
<p class="definition">Definition at line <a class="el" href="qconfig_8c_source.html#l00126">126</a> of file <a class="el" href="qconfig_8c_source.html">qconfig.c</a>.</p>

</div>
</div>
<a id="afe9f5bb5dd171682d5d27e51151eac93" name="afe9f5bb5dd171682d5d27e51151eac93"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afe9f5bb5dd171682d5d27e51151eac93">&#9670;&#160;</a></span>qconfig_parse_str()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">qlisttbl_t * qconfig_parse_str </td>
          <td>(</td>
          <td class="paramtype">qlisttbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>str</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char&#160;</td>
          <td class="paramname"><em>sepchar</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Parse string. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>a pointer of qlisttbl_t. NULL will generate a new table. </td></tr>
    <tr><td class="paramname">str</td><td>key, value pair strings </td></tr>
    <tr><td class="paramname">sepchar</td><td>separater used in configuration file to divice key and value</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of qlisttbl_t in case of successful, otherwise(file not found) returns NULL</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="qconfig_8c.html#afcd4cc94bda4c854e3d26e5e358d5507" title="Load &amp; parse configuration file.">qconfig_parse_file</a></dd></dl>
<div class="fragment"><div class="line">qlisttbl_t *tbl;</div>
<div class="line">tbl = <a class="code hl_function" href="qconfig_8c.html#afe9f5bb5dd171682d5d27e51151eac93">qconfig_parse_str</a>(NULL, <span class="stringliteral">&quot;key = value\nhello = world&quot;</span>, <span class="charliteral">&#39;=&#39;</span>);</div>
<div class="ttc" id="aqconfig_8c_html_afe9f5bb5dd171682d5d27e51151eac93"><div class="ttname"><a href="qconfig_8c.html#afe9f5bb5dd171682d5d27e51151eac93">qconfig_parse_str</a></div><div class="ttdeci">qlisttbl_t * qconfig_parse_str(qlisttbl_t *tbl, const char *str, char sepchar)</div><div class="ttdoc">Parse string.</div><div class="ttdef"><b>Definition</b> <a href="qconfig_8c_source.html#l00216">qconfig.c:216</a></div></div>
</div><!-- fragment --> 
<p class="definition">Definition at line <a class="el" href="qconfig_8c_source.html#l00216">216</a> of file <a class="el" href="qconfig_8c_source.html">qconfig.c</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_40c73bf2095fd0473b1b85ccdcac2768.html">extensions</a></li><li class="navelem"><a class="el" href="qconfig_8c.html">qconfig.c</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.7 </li>
  </ul>
</div>
</body>
</html>
